<?php get_header(); ?>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/magic360/magic360.css" type="text/css" />
<script src="<?php bloginfo('template_url') ?>/magic360/magic360.js" type="text/javascript"></script>
<script type="text/javascript">
  jQuery(document).ready(function() {
    $('.Magic360-button').siblings('div').hide();
  });
  
  Magic360.options = {
    onready: function(spin) { $('.Magic360-button').siblings('div').hide(); }
  }
</script>

<?php
  $id= 128;
  
  $post = get_post($id);
  // print_r($post);
?>
<?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

<div class="track news news-detail single single-product">
  <div class="news-header">
    <h2><?php echo $post->post_title; ?></h2>
  </div>
  <div class="news-content">
    
    <div class="pic-container vshadow4">
      <a href="<?php bloginfo('template_url'); ?>/images/track/01.jpg" class="Magic360" data-magic360-options="autospin: infinite; columns: 10; filename:{col}.jpg; magnify-filename:{col}.jpg;">
				<img src="<?php bloginfo('template_url'); ?>/images/track/01.jpg" />
        <?php
          // $attachments = attachments_get_attachments();
          // $total_attachments = count( $attachments );
          // for( $i=0; $i<$total_attachments; $i++ ) :
        ?>
          <!--<img src="<?php //echo $attachments[$i]['location'] ?>" />-->
        <?php //endfor; ?>
      </a>
      <hr />
    </div>
    
    <div class="product-content">
      <?php echo wpautop($post->post_content); ?>
    </div>

  </div>
  
  <div id="child" style="width: 625px">
  <?php   
    $args = array(
      'numberposts' => -1,
      'category'     => 19,
    );
    $posts = get_posts($args);
    foreach($posts as $post){
    $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
  ?>
  <a href="<?php echo get_permalink($post->ID); ?>">
  <div class="product-box vshadow3 <?php echo $category->category_nicename ?>">
    <?php if(get_field('best_seller', $post->ID)){ ?>
      <div class="tag-best">Best Seller<div class="bar"></div></div>
    <?php } ?>
    
    <div class="product-pic" style="background: url(<?php echo $feat_image; ?>) no-repeat; background-position: center center; background-size: 190px auto;">
    </div>
    <div class="product-info">
      <h3><?php echo substr($post->post_title, 0, 16); ?></h3>
      <p><?php the_field('product_code', $post->ID); ?></p>
    </div>
    <hr />
  </div>
  </a>
  <?php } ?>
  <div class="clear"></div>
  </div>
  <div class="clear"></div>
</div>

<?php get_footer(); ?>